//
//  BSSRequest.h
//  BrightSunnySky
//
//  Created by zhoujunchun on 2019/2/28.
//  Copyright © 2019 PURANG. All rights reserved.
//

#import "YTKRequest.h"

static NSString *const NET_ERROR_NOTIFICATION = @"NET_ERROR_NOTIFICATION";

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger , BSSRequestStatus) {
    /*来自服务器定义*/
    //正常
    BSSRequestStatusSuccess                   = 200,
    BSSRequestStatusLoginUserNotFound         = 404,
    BSSRequestStatusLoginUserPasswordNotRight = 501,
//    BSSRequestStatusLoginInOtherDevice        = 409,     //账号在其他设备登录90004
    /*本地定义*/
    //网络失败
    BSSRequestStatusFailure,
    BSSRequestStatusAccessTokenExpired = 401//失效
};

//使用此类时,ZLRequestBlock始终被传递
typedef void (^BSSRequestBlock)(BSSRequestStatus requestStatus, NSString * __nullable  message, id __nullable responseObject); 

@interface BSSRequest : YTKRequest

@property (nonatomic,   copy) NSString          *urlStr;
@property (nonatomic,   copy) NSDictionary      *dic;
@property (nonatomic, assign) YTKRequestMethod  requestMethod;

- (instancetype)initWithURL:(nonnull NSString *)URLStr
                        dic:(nullable NSDictionary *)dic;

- (instancetype)initWithURL:(nonnull NSString *)URLStr
                        dic:(nullable NSDictionary *)dic
              requestMethod:(YTKRequestMethod)requestMethod;

/// (封装层) 发起请求, 返回自定义对象时需要子类调用
- (void)startRequest:(BSSRequestBlock)requestBlock;


- (void)handleSuccess:(BSSRequestBlock)requestBlock
       responseObject:(id)responseObject
      responseHeaders:(NSDictionary *)responseHeaders;
- (void)handleFailure:(BSSRequestBlock)requestBlock
                error:(NSError *)error
      responseHeaders:(NSDictionary *)responseHeaders;

NS_ASSUME_NONNULL_END

@end
